<meta args="config"/>
<form s="nda,datac,valid" s-data="config" id="form">
    <table class="table table-striped table-bordered">
        <tr>
            <td style="width: 100px;">物料Id</td>
            <td>
                <select class="form-control" s="select"
                        name="materialId"
                        s-build="materialList()">
                    <option value="">默认物料</option>
                </select>
            </td>
        </tr>
    </table>
</form>

<script>
    S.getConfig = function () {
        var deferred = $.Deferred();
        $form.validate().done(function() {
            deferred.resolve(Smart.serializeToObject($form.node))
        })
        return deferred;
    }
    function materialList() {
        var deferred = $.Deferred();
        S.get("/api/setting/TaobaoMaterialSetting").done(function (setting) {
            deferred.resolve(setting.materialList.map(function (m) {
                m.name = '[' + m.id + ']' + m.name
                return m
            }))
        })
        return deferred;
    }

</script>